<template>
  <div>
    <h2>温州理工滨海校区</h2>
    <input 
      v-model="studentId" 
      placeholder="请输入学号" 
      @input="searchStudent" 
    />
    <button @click="searchStudent">搜索</button>
    <div v-if="student">
      <p>学生信息</p>
      <p>学号: {{ student.id }}</p>
      <p>姓名: {{ student.name }}</p>
      <p>年龄: {{ student.age }}</p>
      <p>专业: {{ student.major }}</p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      studentId: '',
      student: null
    };
  },
  methods: {
    searchStudent() {
      // 防止空输入触发搜索
      if (!this.studentId.trim()) {
        this.student = null;
        return;
      }
      // 模拟学生数据查询
      const students = [
        { id: '123456', name: '李小明', age: 18, major: '计算机科学' }
      ];
      this.student = students.find(student => student.id === this.studentId) || null;
    }
  }
};
</script>